<?php

class Ialbum_Widget_FriendPhotosTaggedController extends Engine_Content_Widget_Abstract
{
  public function indexAction()
  {

  	$viewer = Engine_Api::_()->user()->getViewer();
  	if(!$viewer && !$viewer->getIdentity()) return $this->setNoRender();
  	 // Multiple friend mode
    $friends = $viewer->membership()->getMembers();  
    $ids = array();
    foreach ($friends as $friend){
		if($friend->user_id == $viewer->getIdentity()) continue;
    	$ids[] = $friend->user_id;
    }
    $photo_ignore = 0;
    try{
	    $subject = Engine_Api::_()->core()->getSubject();
	   	if($subject && $subject->getType()=='album_photo')
	   		$photo_ignore = $subject->getIdentity();
    }catch (Exception $e){
    	//silence
    }
    $this->view->friendPhotos = $friendPhotos =  Engine_Api::_()->ialbum()->getFreindTaggedPhoto($ids, $this->_getParam('itemCountPerPage', 5), 1, $photo_ignore);
    $friendPhotos->setItemCountPerPage($this->_getParam('itemCountPerPage', 5));
    $friendPhotos->setCurrentPageNumber($this->_getParam('page', 1));
    if ($friendPhotos->count() <= 0) return $this->setNoRender();
  }
}
